package com.drcoffee.drcoffeemall.controller;

import com.drcoffee.drcoffeemall.entry.Machine;
import com.drcoffee.drcoffeemall.entry.Result;
import com.drcoffee.drcoffeemall.entry.Video;
import com.drcoffee.drcoffeemall.service.MachineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.crypto.Mac;
import javax.swing.text.EditorKit;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 机型
 *
 * @author ShiHao Zhou
 */
@RestController
@RequestMapping("/machine")
public class MachineController {


    final
    MachineService machineService;

    public MachineController(MachineService machineService) {
        this.machineService = machineService;
    }


    @GetMapping("/getType")
    public ResponseEntity<Object> getType() {
        return machineService.getType();
    }

    /*
     * 查询机器
     * */
    @GetMapping("/getMachine")
    public Result getMachine(@RequestParam Integer type_id, @RequestParam String search) {
        return machineService.getMachine(type_id,search);
    }

    /*
     * 根据id查询机器
     * */
    @GetMapping("/getMachineById")
    public Map<String, Object> getMachineById(@RequestParam Integer id) {
        return machineService.getMachineById(id);
    }

    @GetMapping("/getMachineId")
    public Result getMachineId(@RequestParam String part_code, @RequestParam String cn_name, @RequestParam String en_name) {
        return machineService.getMachineId(part_code,cn_name,en_name);
    }

    @GetMapping("/getMachineAndAttachment")
    public Result getMachineAndAttachment(@RequestParam List<Integer> id) {
        return machineService.getMachineAndAttachment(id);
    }


}
